<!--
 * @Author: tonghao
 * @Date: 2024-10-11 10:00:40
 * @LastEditors: tonghao
 * @LastEditTime: 2024-10-17 10:09:50
 * @Description: 请填写简介
-->
<script setup lang="ts">
import CustomNavbar from './components/CustomNavbar.vue'
import CategoryPanel from './components/CategoryPane.vue'
import HotPanel from './components/HotPanel.vue'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { getHomeMultidata, getHomeCategoryAPI, getHomeHotAPI } from '@/services/home'
import type { BannerItem, CategoryItem, HotItem } from '@/types/home'
const XtxSwipelist = ref<BannerItem[]>([])
const CategoryPanelList = ref<CategoryItem[]>([])
const HotPanelList = ref<HotItem[]>([])

const getHomeMultidataList = async () => {
  const res = await getHomeMultidata()
  XtxSwipelist.value = res.result
}
const getHomeCategory = async () => {
  const res = await getHomeCategoryAPI()
  CategoryPanelList.value = res.result
}
const getHomeHot = async () => {
  const res = await getHomeHotAPI()
  HotPanelList.value = res.result
}
onLoad(() => {
  getHomeMultidataList()
  getHomeCategory()
  getHomeHot()
})
</script>

<template>
  <CustomNavbar />
  <scroll-view enable-back-to-top refresher-enabled class="scroll-view" scroll-y>
    <XtxSwipe :list="XtxSwipelist" />
    <CategoryPanel :list="CategoryPanelList" />
    <HotPanel :list="HotPanelList" />
    <XtxGuess ref="guessRef" />
  </scroll-view>
</template>

<style lang="scss">
page {
  background-color: #f7f7f7;
  height: 100%;
  overflow: hidden;
}

.viewport {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.scroll-view {
  flex: 1;
  overflow: hidden;
}
</style>
